package ee.pri.pink.kallur.gl.objects;

import java.util.Hashtable;
import java.util.Map;

import android.util.Log;

public class Level {
	public static final GLCube cube = new GLCube();
	
	public static final String LEVEL_TEST = 
		"###########################\n" +
		"#                         #\n" +
		"# ##### #####  ###  ##### #\n" + 
		"#   #   #     #       #   #\n" + 
		"#   #   ###    ###    #   #\n" +
		"#   #   #         #   #   #\n" +
		"#   #   #####  ###    #   #\n" +
		"#                         #\n" + 
		"###########################\n";
	
	private static Map<String, String> levels = new Hashtable<String, String>();
	
	static {
		levels.put("test", LEVEL_TEST);
	}
	
	public static void load(String name, GLWorld world) {
		String level = levels.get(name);
		String[] lines = level.split("\n");
		
		int h = lines.length;
		int w = lines[0].length();
		
		for (int y = 0; y < h; y++) {
			for (int x = 0; x < w; x++) {
				if (". ".indexOf(lines[y].charAt(x)) == -1) {
					world.addObject(cube, (float)x, (float)y, 0.0f);
					Log.d("Kallur", "Adding cube to x=" + x + ", y=" + y);
				}
			}
		}
	}
}
